<?php

namespace Proj\ResManBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Resources
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Proj\ResManBundle\Entity\Repository\ResourcesRepository")
 */
class Resources
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;

    /**
     * @var string
     *
     * @ORM\Column(name="amount", type="string", length=255)
     */
    private $amount;
    
    /**
     * 
     * @var \Doctrine\Common\Collections\ArrayCollection
     * 
     * @ORM\ManyToMany(targetEntity="Activity")
     * @ORM\JoinTable(
     *      name="activity_resources",
     *      joinColumns={@ORM\JoinColumn(name="resources_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="activity_id", referencedColumnName="id")}
     * )
     **/
    private $activities;


    
    /**
     * 
     * @var Department
     * 
     * @ORM\ManyToOne(targetEntity="Department", inversedBy="resources")
     * @ORM\JoinColumn(name="department_id", referencedColumnName="id")
     */
 
    private $department;
 
    //0 for financial, 1 for mat&equip, 2 for rooms
     /**
     * @var string
     *
     * @ORM\Column(name="type", type="string", length=255)
     */
    private $type;

    /**
     *
     * @var \Doctrine\Common\Collections\ArrayCollection
     * 
     * @ORM\OneToMany(targetEntity="TaskResources", mappedBy="resources")
     */
    private $taskResources;
    

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Resources
     */
    public function setName($name)
    {
        $this->name = $name;
    
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set amount
     *
     * @param string $amount
     * @return Resources
     */
    
    
    public function setAmount($amount)
    {
        $this->amount = $amount;
    
        return $this;
    } 

    /**
     * Get amount
     *
     * @return string 
     */
    
      
    public function getAmount()
    {
        return $this->amount;
    }
    
        /**
     * Set type
     *
     * @param integer $type
     * @return Resources
     */
    
    
        public function setType($type)
    {
        $this->type = $type;
    
        return $this;
    }
    
    /**
     * Get type
     *
     * @return int 
     */
   
    public function getType()
    {
        return $this->type;
    }
    
    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('name', new NotBlank(array(
            'message' => 'Trebuie sa introduceti denumirea resursei.'
        )));
        $metadata->addPropertyConstraint('department', new NotBlank(array(
            'message' => 'Trebuie sa selectati departamentul.'
        )));
        $metadata->addPropertyConstraint('amount', new Assert\Range(array(
            'min'        => 1,
            'minMessage' => 'Cantitatea trebuie sa fie un numar pozitiv.'
        )));
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->activities = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Add activities
     *
     * @param \Proj\ResManBundle\Entity\Activity $activities
     * @return Resources
     */
    public function addActivity(\Proj\ResManBundle\Entity\Activity $activities)
    {
        $this->activities[] = $activities;

        return $this;
    }

    /**
     * Remove activities
     *
     * @param \Proj\ResManBundle\Entity\Activity $activities
     */
    public function removeActivity(\Proj\ResManBundle\Entity\Activity $activities)
    {
        $this->activities->removeElement($activities);
    }

    /**
     * Get activities
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getActivities()
    {
        return $this->activities;
    }

    /**
     * Set department
     *
     * @param \Proj\ResManBundle\Entity\Department $department
     * @return Resources
     */
    public function setDepartment(\Proj\ResManBundle\Entity\Department $department = null)
    {
        $this->department = $department;

        return $this;
    }

    /**
     * Get department
     *
     * @return \Proj\ResManBundle\Entity\Department 
     */
    public function getDepartment()
    {
        return $this->department;
    }

    /**
     * Add tasks
     *
     * @param \Proj\ResManBundle\Entity\Task $tasks
     * @return Resources
     */
    public function addTask(\Proj\ResManBundle\Entity\Task $tasks)
    {
        $this->tasks[] = $tasks;

        return $this;
    }

    /**
     * Remove tasks
     *
     * @param \Proj\ResManBundle\Entity\Task $tasks
     */
    public function removeTask(\Proj\ResManBundle\Entity\Task $tasks)
    {
        $this->tasks->removeElement($tasks);
    }

    /**
     * Get tasks
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getTasks()
    {
        return $this->tasks;
    }

    /**
     * Add taskResources
     *
     * @param \Proj\ResManBundle\Entity\TaskResources $taskResources
     * @return Resources
     */
    public function addTaskResource(\Proj\ResManBundle\Entity\TaskResources $taskResources)
    {
        $this->taskResources[] = $taskResources;

        return $this;
    }

    /**
     * Remove taskResources
     *
     * @param \Proj\ResManBundle\Entity\TaskResources $taskResources
     */
    public function removeTaskResource(\Proj\ResManBundle\Entity\TaskResources $taskResources)
    {
        $this->taskResources->removeElement($taskResources);
    }

    /**
     * Get taskResources
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getTaskResources()
    {
        return $this->taskResources;
    }
}
